package cn.wolfcode.p2p.business.task;

import cn.wolfcode.p2p.business.service.IActiveWaterService;
import cn.wolfcode.p2p.business.service.IBidRequestService;
import cn.wolfcode.p2p.business.service.IStatisticsDayFlowService;
import cn.wolfcode.p2p.business.service.IStatisticsMonthFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 定时器
 */
@Component
public class SimpleTask {
    @Autowired
    private IBidRequestService bidRequestService;

    @Autowired
    private IActiveWaterService activeWaterService;

    @Autowired
    private IStatisticsMonthFlowService statisticsMonthFlowService;

    @Autowired
    private IStatisticsDayFlowService statisticsDayFlowService;


    //定时发标
    @Scheduled(cron = "*/5 * * * * *")
    public void publishForBidding(){
        bidRequestService.publishForBidding();
    }

    //定时查询数据库中待发标的数据
    //@Scheduled(cron = "0 0 0/1 * * *")
    @Scheduled(cron = "*/5 * * * * *")
    public void listBidRequests(){
        bidRequestService.listBidRequests();
    }

    //定时查询逾期情况
    //@Scheduled(cron = "0 0 0 */1 * ?")
    @Scheduled(cron = "*/20 * * * * *")
    public void queryOverdue(){
        bidRequestService.overdue();
    }

    //计算滞纳金
    //@Scheduled(cron = "0 0 0 */1 * ?")
    @Scheduled(cron = "0 */1 * * * *")
    public void latePayment(){
        bidRequestService.latePayment();
    }

    //回收体验金
    //@Scheduled(cron = "0 0 0 */1 *
    @Scheduled(cron = "*/5 * * * * *")
    public void recyclingExperience(){
        bidRequestService.recyclingExperience();
    }

    /*//生成活跃流水
    @Scheduled(cron = "0/10 * * * * ?")
    public void createActiveWater(){
        activeWaterService.createActiveWater();
    }*/

    //每日统计流水
    @Scheduled(cron = "5 0 0 * * ?")
    public void statisticsForDay(){
        statisticsDayFlowService.statisticsForDay();
    }
    //每月统计流水
    @Scheduled(cron = "59 59 23 L 1/1 ?")
    public void statisticsForMonth(){
        statisticsMonthFlowService.statisticsForMonth();
    }
}
